﻿// ////////////////////////////////////////////////////////////////////////////
// 
// SWE Case Tool
// 
// Solution:	CaseTool
// Project:		2. CaseTool GUI
// Filename:	FrmList.cs
// 
// File Created:	02:06 31.05.2013 
// Last Changed:	18:11 05.06.2013
// 
// ////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;

namespace SWE.CaseTool.GUI
{
	/// <summary>
	/// A simple dialog with direct databinding to a c# datagridview. Not very user friendly, but easy to
	/// implement and it fits the requirements.
	/// </summary>
	/// <typeparam name="T">T is the type which will be bound to the grid view.</typeparam>
	public partial class FrmList<T> : Form
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="FrmList{T}" /> class.
		/// </summary>
		/// <param name="data">The data which will be editied within this dialog.</param>
		/// <param name="title">The dialog title.</param>
		public FrmList(IList<T> data, string title)
		{
			InitializeComponent();
			Text = title;
			dataGridView1.DataSource = new BindingList<T>(data);
		}

		/// <summary>
		/// Closes the dialog. Because of the direct databinding no actions are required to save the changes.
		/// </summary>
		/// <param name="sender">The sender.</param>
		/// <param name="e">
		/// The <see cref="EventArgs" /> instance containing the event data.
		/// </param>
		private void BtnOkClick(object sender, EventArgs e) { Close(); }
	}
}